package cc.javaee.bbs.tool;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class PropertiesUtil {

    private static final Properties prop = new Properties();

    //配置文件读取
    private static String getConfigProperties() {
        return "config.properties";
    }

    /**
     * 读取配置文件获取值
     *
     * @return
     */
    public static String getProperties(String key) {
        if (!prop.contains(key)) {
            ClassLoader classLoader = PropertiesUtil.class.getClassLoader();
            try (InputStream ism = classLoader.getResourceAsStream(getConfigProperties())) {
                prop.load(ism);
                prop.size();
            } catch (Exception e) {
                throw new IllegalAccessError("读取ftp属性文件失败");
            }
        }
        return prop.getProperty(key);
    }

}
